// import { clipboard } from '@ve/utils/clipboard'
// import { jsonToTable } from '@ve/utils/jsonToTable'

import isEmpty from 'lodash/isEmpty'

//必须带done回调 执行完成调用
export default function showIdentifyBox({ vm, action, done, callbackData }) {
  let { moduleSelect } = action.extension

  let corRes = []
  if (!isEmpty(moduleSelect.value)) {
    const moduleSelf = vm.vuiComponents[moduleSelect.value[0]]?.self

    if (moduleSelf) {
      // 调用识别方法
      try {
        window.$CIMC.ocrRecognite((res) => {
          if (res) {
            const result = JSON.parse(res)
            corRes = result.data || []
          }
          moduleSelf && moduleSelf.showPopup(corRes)
          done(null, corRes)
        })
      } catch (error) {
        console.warn(error)
        moduleSelf && moduleSelf.showPopup(corRes)
        done(null, corRes)
      }

    } else {
      moduleSelf && moduleSelf.showPopup(corRes)
      done(null, corRes)
    }

  } else {
    done(null, corRes)
  }
}
